package com.tmallgo.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

@Component("exceptionResolver")
public class ErrorResolveController implements HandlerExceptionResolver{
	private static final Logger logger=Logger.getLogger(ErrorResolveController.class);
	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception ex) {
		ModelAndView mav=new ModelAndView();
		mav.setViewName("error");
		mav.addObject("msg", ex.getMessage());
		logger.error(ex.getMessage(),ex);
		return mav;
	}

}
